package com.xsz.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.*;

import com.xsz.entity.OrderMaster;

@RestController
public class TestParameterController {
	
	   //路径传值
	//http://localhost:9001/springboot1/t1/aaaa
		@RequestMapping("t1/{p1}")
		public Map t1(@PathVariable("p1") String paramter1){
			Map map=new HashMap();
			map.put("rs",paramter1);
			return  map;
		}
		//? 传值
		//http://localhost:9001/springboot1/t2?p1=aaaa
		@RequestMapping("t2")
		public Map t2(@RequestParam("p1") String paramter1)
		{
			System.out.println(paramter1);
			Map map=new HashMap();
			map.put("rs",paramter1);
			return  map;
		}

		//Body参数
	   //application/jason
		@RequestMapping("t3")
		public Map t3(@RequestBody OrderMaster master){

			Map map=new HashMap();
			map.put("rs",master.getUserName());
			return  map;
		}
//		无注解（form提交）
		//form-data
		@RequestMapping("t4")
		public Map t4(OrderMaster master){

			Map map=new HashMap();
			map.put("rs",master.getUserName());
			return  map;
		}

//		请求头参数以及Cookie
		@RequestMapping("t5")
		public Map t5(@RequestHeader(name ="myHeader") String myHeader,
						 @CookieValue(name = "myCookie") String myCookie){
			System.out.println("myHeader=" + myHeader);
			System.out.println("myCookie=" + myCookie);
			Map map=new HashMap();
			map.put("rs",myHeader);
			return  map;
		}

//		表单的参数写在Controller相应的方法的形参中
//		适用于get方式提交，不适用于post方式提交。
		@RequestMapping("t6")
		public Map t6(String name,String pwd){

			Map map=new HashMap();
			map.put("rs",name);
			return  map;
		}

}
